﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BrnMall.Core;

namespace BrnMall.Web.StoreAdmin.Models
{
    #region 组件
    public class PageInfo
    {
        public string Id { get; set; }
        public string Url { get; set; }
        public string Name { get; set; }
    }
    public class FunctionCodeInfo
    {
        public string Name { get; set; }
        /// <summary>
        /// 小程序功能(扫一扫)
        /// </summary>
        public string FunctionCode { get; set; }
    }


    public static class PageInfoConfig
    {
        public static List<PageInfo> Pages { get; set; }

        public static PageInfo Get(string id)
        {
            return Pages.FirstOrDefault(page => page.Id == id);
        }

        static PageInfoConfig()
        {
            Pages = new List<PageInfo>
            {
                new PageInfo() {Id = "1",Url = "/pages/member/coupon/index?st=2", Name = "领券中心"},
                new PageInfo() {Id = "2",Url = "/pages/about/index?tap=0", Name = "关于我们"},
                new PageInfo() {Id = "3",Url = "/pages/kefu/index", Name = "在线客服"},
                new PageInfo() {Id = "4",Url = "/fenxiao/index/index", Name = "申请分销"},
                new PageInfo() {Id = "5",Url = "/pages/yuyue/index", Name = "预约留言"},
                new PageInfo() {Id = "6",Url = "/pages/about/index?tap=1", Name = "联系方式"},
                new PageInfo() {Id = "7",Url = "/pages/about/index?tap=2", Name = "一键导航"},
                new PageInfo() {Id = "8",Url = "/pages/groupbuy/index", Name = "拼团活动"},
                new PageInfo() {Id = "9",Url = "/pages/TimeProduct/index", Name = "限时秒杀"},
                new PageInfo() {Id = "10",Url = "/pages/content-list/index", Name = "留言管理"},   //留言版块   20180109
                new PageInfo() {Id = "11",Url = "/pages/classes/index", Name = "所有商品"},
                new PageInfo() {Id = "12",Url = "", Name = "无链接"},                              //无链接，首页轮播图、图片组件用 20180109
                new PageInfo() {Id = "13",Url = "/pages/storeList/index", Name = "附近门店"},      //附近门店 20180124
                new PageInfo() {Id = "14",Url = "/pages/payFace/index", Name = "当面付"},
                new PageInfo() { Id="15",Url="/pages/queueNumber/index",Name="排队"},
                new PageInfo() { Id="16",Url="/pages/predetermine/index",Name="餐位预约"}
            };
        }
    }
    /// <summary>
    /// 小程序功能(扫一扫)
    /// </summary>
    public static class FunctionCodeInfoConfig
    {
        /// <summary>
        /// 小程序功能(扫一扫)
        /// </summary>
        public static List<FunctionCodeInfo> FunctionCodes { get; set; }

        public static FunctionCodeInfo Get(string Name)
        {
            return FunctionCodes.FirstOrDefault(page => page.Name == Name);
        }

        static FunctionCodeInfoConfig()
        {
            FunctionCodes = new List<FunctionCodeInfo>
            {
                new FunctionCodeInfo() {Name = "扫一扫",FunctionCode="scancode"},
                new FunctionCodeInfo() {Name = "客服",FunctionCode="contact"}
            };
        }
    }
    /// <summary>
    /// 组件配置
    /// </summary>
    public class WidgetConfigModel
    {
        [DisplayName("主键")]
        public int CId { get; set; }

        [DisplayName("组件ID")]
        public int WId { get; set; }
        [DisplayName("显示名称")]
        public string ShowName { get; set; }
        [DisplayName("显示图片")]
        public string ShowImg { get; set; }
        [DisplayName("链接类型")]
        public string LinkType { get; set; }
        [DisplayName("链接参数")]
        public LinkValue LinkValue { get; set; }
        [DisplayName("排序")]
        public int DisplayOrder { get; set; }
        [DisplayName("是否显示")]
        public bool IsShow { get; set; }
        /// <summary>
        /// 展示数量，当连接类型为商品时，挑选指定数量的商品
        /// </summary>
        public int DisplayCount { get; set; }
        /// <summary>
        /// 展示类型
        /// </summary>
        public int DisplayType { get; set; }
        /// <summary>
        /// 组件的位置
        /// 0：未定义， 1:首页搜索框下，2：首页导航按钮下，3：首页内容下，4：首页商品下
        /// </summary>
        public int DisplayPosition { get; set; }

        public WidgetConfigModel()
        {
            CId = WId = 0;
            ShowName = ShowImg = LinkType = string.Empty;
            DisplayOrder = DisplayCount = DisplayType = DisplayPosition = 0;
            IsShow = true;
            LinkValue = new LinkValue();
        }
    }

    /// <summary>
    /// 组件添加模型
    /// </summary>
    public class WidgetConfigPostModel
    {
        /// <summary>
        /// 组件编码
        /// </summary>
        public string Code { get; set; }

  
        public int CId { get; set; }


        public int WId { get; set; }
     public bool WidgetDisplayType { get; set; }
        public string ShowName { get; set; }
    
        public string ShowImg { get; set; }
 
        public string LinkType { get; set; }
   
        public string LinkValue { get; set; }

        public int DisplayOrder { get; set; }

        public bool IsShow { get; set; }

        public string Pid { get; set; }
        public string ProductName { get; set; }
        public string StoreClassId { get; set; }
        public string StoreClassName { get; set; }
        public string NewsTypeId { get; set; }
        public string NewsTypeName { get; set; }
        public string NewsId { get; set; }
        public string NewsName { get; set; }
        public string PageInfoId { get; set; }
        /// <summary>
        /// 暂时数量，当连接类型为商品时，挑选指定数量的商品
        /// </summary>
        public int DisplayCount { get; set; }
        /// <summary>
        /// 展示类型
        /// </summary>
        public int DisplayType { get; set; }
        /// <summary>
        /// 商品特征,精品，热销，新品
        /// </summary>
        public string ProductAttr { get; set; }
        /// <summary>
        /// 链接到H5Page时的网页地址
        /// </summary>
        public string H5Page { get; set; }
        /// <summary>
        /// 一键拨号的号码
        /// </summary>
        public string PhoneNumber { get; set; }
        /// <summary>
        /// 小程序功能(扫一扫)
        /// </summary>
        public string FunctionCode { get; set; }

        public WidgetConfigPostModel()
        {
            CId = WId = 0;
            ShowName = ShowImg = LinkType = LinkValue = Pid = ProductName = StoreClassId = StoreClassName
                = NewsTypeId = NewsTypeName = NewsId = NewsName = PageInfoId = ProductAttr = FunctionCode=string.Empty;
            DisplayOrder = DisplayCount = DisplayType =0;
            IsShow = true;
            WidgetDisplayType = false;
            H5Page = PhoneNumber= string.Empty;
        }
    }
    /// <summary>
    /// 组件添加模型
    /// </summary>
    public class IndexPictureWidgetConfigPostModel
    {
        /// <summary>
        /// 组件编码
        /// </summary>
        public string Code { get; set; }
        public int CId { get; set; }
        public int WId { get; set; }
        public string ShowName { get; set; }
        public int DisplayOrder { get; set; }
        public bool IsShow { get; set; }
        /// <summary>
        /// 展示类型
        /// </summary>
        public int DisplayType { get; set; }
        /// <summary>
        /// 展示区域
        /// </summary>
        public int DisplayPosition { get; set; }

        public IndexPictureWidgetConfigPostModel()
        {
            CId = WId = 0;
            ShowName = string.Empty;
            DisplayOrder = DisplayType = DisplayPosition = 0;
            IsShow = true;
        }
    }

    public class EditIndexPictureWidgetCustomerFeaturesModel
    {
        public IList<LinkValue> CustomerFeatures { get; set; }
        public WidgetConfigModel WidgetConfig { get; set; }
        public IList<StoreClassInfo> StoreClassList { get; set; }
        public IList<NewsTypeInfo> NewsTypeList { get; set; }
        public IList<PageInfo> PageInfos { get; set; }
        public IList<FunctionCodeInfo> FunctionCodes { get; set; }
        public IList<string> LinkArea { get; set; }
        public IList<string> UploadTips { get; set; }

        public EditIndexPictureWidgetCustomerFeaturesModel()
        {
            CustomerFeatures=new List<LinkValue>();
            WidgetConfig=new WidgetConfigModel();
            StoreClassList=new List<StoreClassInfo>();
            NewsTypeList=new List<NewsTypeInfo>();
            PageInfos=new List<PageInfo>();
            FunctionCodes = new List<FunctionCodeInfo>();
            LinkArea=new List<string>();
            UploadTips=new List<string>();
        }

    }
    public class EditIndexPictureWidgetCustomerFeaturesPostModel
    {
        


        public int CId { get; set; }
        public string LinkArea { get; set; }

        public string ShowImg { get; set; }

        public string LinkType { get; set; }

        public string LinkValue { get; set; }

        public string Pid { get; set; }
        public string ProductName { get; set; }
        public string StoreClassId { get; set; }
        public string StoreClassName { get; set; }
        public string NewsTypeId { get; set; }
        public string NewsTypeName { get; set; }
        public string NewsId { get; set; }
        public string NewsName { get; set; }
        public string PageInfoId { get; set; }

        /// <summary>
        /// 链接到H5Page时的网页地址
        /// </summary>
        public string H5Page { get; set; }
        /// <summary>
        /// 一键拨号的号码
        /// </summary>
        public string PhoneNumber { get; set; }
        /// <summary>
        /// 小程序功能(扫一扫)
        /// </summary>
        public string FunctionCode { get; set; }
        public EditIndexPictureWidgetCustomerFeaturesPostModel()
        {
            CId =0;
            ShowImg = LinkType = LinkValue = Pid = ProductName = StoreClassId = StoreClassName
                = NewsTypeId = NewsTypeName = NewsId = NewsName = PageInfoId = LinkArea= FunctionCode=string.Empty;
            H5Page = PhoneNumber = string.Empty;

        }

    }

    /// <summary>
    /// 图片链接
    /// </summary>
    public class LinkValue
    {
        public string Id { get; set; }
        public string Name { get; set; }
        public string Url { get; set; }
        public string LinkType { get; set; }
        public string ShowImg { get; set; }
        public string LinkArea { get; set; }

        public LinkValue()
        {
            Id = Name = Url = LinkType = ShowImg = LinkArea= string.Empty;

        }
    }

    public class WidgetModel
    {
        [DisplayName("组件ID")]
        public int WId { get; set; }
        [DisplayName("组件代码")]
        public string Code { get; set; }
        [DisplayName("店铺ID")]
        public int StoreId { get; set; }
        [DisplayName("组件名称")]
        public string Name { get; set; }
        [DisplayName("展示类型")]
        public int DisplayType { get; set; }
    }

    public class WidgetConfigListModel
    {
        public IList<WidgetConfigModel> Config { get; set; }
        public WidgetModel Widget { get; set; }
        public IList<StoreClassInfo> StoreClassList { get; set; }
        public IList<NewsTypeInfo> NewsTypeList { get; set; }
        public IList<PageInfo> PageInfos { get; set; }
        /// <summary>
        /// 小程序功能
        /// </summary>
        public IList<FunctionCodeInfo> FunctionCodes{ get; set; }
        public string Code { get; set; }
        /// <summary>
        /// 上传图片尺寸的提示
        /// </summary>
        public string UploadImageTips { get; set; }

        /// <summary>
        /// 单个组件实体
        /// </summary>
        public Manager.Domain.Store.WidgetConfig configModel { get; set; }

    }
    #endregion
}
